<include file="Public:header" />
<!--主体内容-->
<!--左边-->
<div class="centent_box">
    <include file="Public:left" />
    <!--右边-->
    <div class="centent_right_box">
        <div class="centent_right rightCon">
            <div class="Mtitle">
                <ul>
                    <li class="on"><span>系统设置</span></li>
                </ul>
                <div class="rightWord"><a href="{:U('Set/estates')}">小区设置</a> &gt;&gt; 编辑小区</div>
            </div>
            <form id="info_form" action="{:U('Set/edit_estate')}" method="post" enctype="multipart/form-data">
            <div class="con_div">
                <ul class="formList width2 list_ul list_mp">
                    <li>
                        <label>小区名称：</label>
                        <input type="text"  name="data[title]" id="title" class="inputStyle width3" value="{$estate.title}">
                    </li>
                    <li class="clear" id="area-sele">
                        <label>区域范围：</label>
                        <select class="selectStyle" name="area" id="area" onclick="getArea(this)" onchange="seleArea(this)">
                            <option value="0">--请选择--</option>
                            <option value="1">深圳</option>
                        </select>

                    </li>
                    <li>
                        <label>总共多少栋：</label>
                        <input type="number" class="inputStyle" width="20px" name="data[build]" value="{$estate.build}" >
                    </li>
                    <li class="dict-info">
                        <label >地址：</label>
                        <input type="text"  name="data[address]"  class="inputStyle width3" value="{$estate.address}">
                    </li>
                    <li>
                        <label>建筑年代：</label>
                        <input type="number" class="inputStyle width2" name="data[years]" maxlength="10" id="years" value="{$estate.years}">
                        <span class="tip">年</span>
                    </li>
                    <li>
                        <label>地图标注：</label>
                        <input type="text" class="inputStyle" name="data[map]" id="map" value="{$estate.map}">
                        <span class="tip"><a target="_blank" style="padding: 4px 8px;color:#ffffff;background: orange" href="http://api.map.baidu.com/lbsapi/getpoint/">获取百度地图坐标</a></span>
                    </li>
                    <li id="files">
                        <label>多图上传：</label>
                        <script id="uploadpic" name="uploadpic" type="text/plain"></script>
                        <input type="button" class="btn btn_submit" style="margin:0 0 10px 10px;" onclick="upImage();" value="选择图片">
                        <div id="imageList">
                            <ul class="list clearfix"></ul>
                        </div>
                        <input type="hidden" name="file" id="file" />
                    </li>
                    <li><label>缩例图：</label><input type="file" name="img"></li>



                    <li class="">
                        <label>详细介绍：</label>
                        <textarea name="data[desc]" style="width: 680px;height: 60px;" >{$estate.desc}</textarea>
                    </li>
                    <li>
                        <input type="hidden" name="data[area_id]" id="res-area" value="{$estate.area_id}">
                        <input type="hidden" name="data[id]"  value="{$estate.id}">
                    </li>
                    <li>
                        <label></label>
                        <input type="submit" value="提 交" class="btnStyle">
                    </li>
                </ul>
            </div>
            </form>
        </div>
    </div>
</div>
<js file="__S__/ueditor/ueditor.config.js" charset="utf-8" />
<js file="__S__/ueditor/ueditor.all.min.js" charset="utf-8" />
<js file="__S__/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" />
<js file="__JS__/uploadImg.js" charset="utf-8" />
<script type="text/javascript">
    window.UEDITOR_HOME_URL='__STATIC__/ueditor/';
    window.onload=function(){
        window.UEDITOR_CONFIG.initialFrameWidth=880;
        window.UEDITOR_CONFIG.initialFrameHeight=500;
        upmoreimg();
    }
    var ue = UE.getEditor('info', {
        toolbars: [[
            'fullscreen', 'source', '|',
            'bold', 'italic', 'underline', '|', 'fontfamily','fontsize', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', 'simpleupload','|', 'kityformula', 'preview'
        ]]
    });
</script>
<script src="__S__/js/jquery.validate.js"></script>
<script type="text/javascript">
    $(function(){
        $("#info_form").validate({
            rules: {
                "data[title]": {
                    required: true,
                    minlength: 2
                },
                "data[area_id]": {
                    area:true
                },
                "data[area]": {
                    required: true,
                    minlength: 2
                },
                "data[floor]": {
                    required: true
                },
                "data[total_price]": {
                    required: true
                },
                "used_type[]": {
                    required: true,
                    minlength: 2
                },
                "data[years]": {
                    required: true,
                    minlength: 4
                },
                "data[address]": {
                    required: true,
                    minlength: 5
                },
                "data[map]": {
                    required: true,
                    minlength: 10
                },
                "data[contacts]":{
                    required: true
                },
                "data[phone]":{
                    required: true
                }

            },
            messages: {
                "data[title]": {
                    required: "请输入房源名称",
                    minlength: "房源名称一定要两个字以上"
                },
                "data[area]": {
                    required: "请输入房源面积",
                    minlength: "房源面积一定要两个字以上"
                },
                "data[floor]": {
                    required: "请填写所在楼层"
                },
                "data[total_price]": {
                    required: "请填写房源总价"
                },
                "used_type[]": {
                    required: "楼盘类型一定要选择",
                    minlength: "楼盘类型选择两种以上"
                },
                "data[years]": {
                    required: "请填写房源年份",
                    minlength: "请输入正确的房源年份"
                },
                "data[address]": {
                    required: "请填写房源所在地址",
                    minlength: "房源所在地址请写详细点"
                },
                "data[map]": {
                    required: "输入房源百度地图坐标",
                    minlength: "请输入正确的房源地图坐标"
                },
                "data[contacts]": {
                    required: "输入出售联系人"
                },
                "data[phone]": {
                    required: "请输入联系电话"
                }
            }
        });

        //所属地区
        $.validator.addMethod("area", function(value, element) {
           if($("#area_id").val()!=0){
               return true
           }else{
               return false
           }
        }, "请选择所属地区");
    });
    function getArea (tar){
        var areaid = $(tar).val();
        var sele = $(tar);
        if (areaid == 0) {
            $(sele).nextAll('select').remove();
            return false;
        }
        var url = "{:U('Ajax/getArea')}", data = {areaid:areaid};
        $.post (url, data, function (response){
            var html = '';
            if (response.state == 'ok'){
                var data = response.data;
                html = '<select class="selectStyle area" name="area" onclick="getArea(this)" onchange="seleArea(this)"><option value="0">--请选择--</option>';
                $.each(data, function (i, v){
                    html += '<option value="'+v.id+'">'+v.name+'</option>';
                });
                html += '</select>';
            }
            console.log($(sele));
            $(sele).nextAll('select').remove();
            $('#area-sele').append(html);
        }, 'json');
    }
    function seleArea(tar) {
        var sele_val = $(tar).val();
        $('#res-area').val(sele_val);
    };


</script>
<include file="Public:footer" />